import moment from 'moment';
import { Toast } from 'antd-mobile';
import { routerRedux } from 'dva/router';
import { wxPay, unionPay } from '../services/weixin';
import { source, update } from  '../services/component';
import { lists,duty } from '../services/Personalinformation';


const empty = require('is-empty');
export default {
  namespace:'mem',
  state:{},

  subscriptions:{
    setup({dispatch, history}) {
      history.listen(({pathname, query}) => {
        if(pathname.toString() == "/work/myinformmation"){
          dispatch({type: 'Meminfo',
            payload: {
            }
          });
        }
      });
    }
  },
  effects: {
    *Meminfo({ payload }, { call,put,select }) {
      // const userdata = sessionStorage.getItem("userdata");
      // const c = JSON.parse(userdata)
      // // console.log(c,"ccccccccccccccccccccccccccc")
      // let r= c[0].administrator[4].member_code
      //console.log(r,"userdata1111111111111111111111111111")
      const data = yield call(lists, {code:"U707517560978935987",relation:["org","extend","infos"]});
      console.log(data,"data");
      yield put({
        type: 'success',
        payload: {
          id:data.data.ret.id,
          name:data.data.ret.name,
          phone:data.data.ret.phone,
          idcard:data.data.ret.idcard,
          type:data.data.ret.type,
          short_name:data.data.ret.org.short_name,
          join_org_date:data.data.ret.join_org_date,
          full_member_date:data.data.ret.full_member_date
        },
      })
    }
  },

  reducers: {
    success(state, action) {
      return {...state, ...action.payload};
    }
  }
}
